package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HoFeedbackComplaint;
import com.ruoyi.system.service.IHoFeedbackComplaintService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 反馈与投诉Controller
 *
 * @author ruoyi
 * @date 2025-01-10
 */
@RestController
@RequestMapping("/system/feedbackComplaint")
public class HoFeedbackComplaintController extends BaseController {
    @Autowired
    private IHoFeedbackComplaintService hoFeedbackComplaintService;

    /**
     * 查询反馈与投诉列表
     */
    @PreAuthorize("@ss.hasPermi('system:feedbackComplaint:list')")
    @GetMapping("/list")
    public TableDataInfo list(HoFeedbackComplaint hoFeedbackComplaint) {
        startPage();
        List<HoFeedbackComplaint> list = hoFeedbackComplaintService.selectHoFeedbackComplaintList(hoFeedbackComplaint);
        return getDataTable(list);
    }

    /**
     * 导出反馈与投诉列表
     */
    @PreAuthorize("@ss.hasPermi('system:feedbackComplaint:export')")
    @Log(title = "反馈与投诉", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HoFeedbackComplaint hoFeedbackComplaint) {
        List<HoFeedbackComplaint> list = hoFeedbackComplaintService.selectHoFeedbackComplaintList(hoFeedbackComplaint);
        ExcelUtil<HoFeedbackComplaint> util = new ExcelUtil<HoFeedbackComplaint>(HoFeedbackComplaint.class);
        util.exportExcel(response, list, "反馈与投诉数据");
    }

    /**
     * 获取反馈与投诉详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:feedbackComplaint:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(hoFeedbackComplaintService.selectHoFeedbackComplaintById(id));
    }

    /**
     * 新增反馈与投诉
     */
    @PreAuthorize("@ss.hasPermi('system:feedbackComplaint:add')")
    @Log(title = "反馈与投诉", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HoFeedbackComplaint hoFeedbackComplaint) {
        return toAjax(hoFeedbackComplaintService.insertHoFeedbackComplaint(hoFeedbackComplaint));
    }

    /**
     * 修改反馈与投诉
     */
    @PreAuthorize("@ss.hasPermi('system:feedbackComplaint:edit')")
    @Log(title = "反馈与投诉", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HoFeedbackComplaint hoFeedbackComplaint) {
        return toAjax(hoFeedbackComplaintService.updateHoFeedbackComplaint(hoFeedbackComplaint));
    }

    /**
     * 删除反馈与投诉
     */
    @PreAuthorize("@ss.hasPermi('system:feedbackComplaint:remove')")
    @Log(title = "反馈与投诉", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(hoFeedbackComplaintService.deleteHoFeedbackComplaintByIds(ids));
    }
}
